<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>收藏的Agent-会员中心</title>
	<link rel="stylesheet" href="css/xingchao.css">
    <link rel="stylesheet" href="css/jquery.page.css">
     <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/layer/layer.js"></script>
    <script type="text/javascript" src="js/jquery.page.js"></script>
</head>
<body style="background: #EFEFEF;">

<!--  
	头部
-->
<div class="head">
	<div class="w" style="height:50px;">
		<a href="index.html">
			<img src="images/logo.png" alt="" width="150px;">
		</a>
		<ul class="nav r">
	       <li class="cur">
	            <a href="index.html">众源</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="ziyuan.html">资源搜索</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="jiaocheng.html">使用教程</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="biaozhun.html">众源标准</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="page.html">关于我们</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="user.html" id="user-box">会员中心</a>|<a href="user.html?action=out">退出</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="">中文</a>|<a href="">English</a>
	            <sub class="sub1"></sub>
	        </li>
		</ul>
	</div>
</div>

<div class="main w">
<!--  
	当前位置
-->
	<div class="position">
		您当前位置：<a href="">首页</a> > <a href="">会员中心</a>
	</div>
<!--  
	会员信息
-->
	<div class="user">
		<div class="user_left l">
			<div class="left_t">会员中心</div>
			<ul class="left_c">
				
                <li><a href="agent.html" style="color: #5fadfc;">我的收藏</a></li>
                <li><a href="user.html">资料修改</a></li>
                <li><a href="editpwd.html">修改密码</a></li>
				 <li><a href="key.html">Key管理</a></li>
			</ul>
		</div>
		<div class="user_right r">
			<div class="right_t">收藏的agent</div>
			<div class="right_c">
				<!-- agent列表 
				<table width="100%" border="1" cellspacing="0" cellpadding="0" class="form tr_line">
                    <thead>
                    <tr>
                        <th width="50%" align="left">标题</th>
                        <th width="50%" align="left">描述</th>
                        <th width="15%">操作</th>
                    </tr>
                    </thead>
					<tbody id="agentBody">
					</tbody>
				</table>
                 <div id="pageNav" data-all="0"></div>
				新列表，你看下对不
             	-->
              <div id="agentBody">
				<div class="nes_list">
				    <div class="nes_list_l">    
				        <img src="" />
            		</div>
                    <div class="nes_list_r">
                    	<h6>
                    		公司新闻标题
                    		<a href="" style="float:right">删除收藏</a>
                    	</h6>
                    	<p>公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加公司新闻标题，随便写的正在后台加
                    	</p>
                    </div>
                    <div class="clear"></div>
                </div>
          </div>
 <div id="pageNav" data-all="0"></div>
			</div>
		</div>
	</div>
	<div class="clear"></div>
</div>
<!--  
	底部
-->


</body>
</html>
<script type="text/javascript" src="js/App.min.js"></script>
<script type="text/javascript">
var searchConfig ={
		pageSize:10,
		page:1,
	    condition:0
}
$(function(){
	
	setTimeout(function(){ getAgent(1);},10);
	
})
function getAgent(page){
	searchConfig.page = page;
    var url = "http://www.usources.cn/api/agent/userCollects";
    totalPages   = $("#pageNav").data('all');
    var loading = layer.msg('正在获取所有收藏，请等候...', {icon: 16,time: 999999, shade: [0.3, '#000']});

   $.ajax({
	  url:url+'?'+Math.random(),
	  type:'GET',
	   xhrFields: {
	   withCredentials: true
	  },
	  crossDomain:true,
	  data:{pageNo:searchConfig.page,pageSize:searchConfig.pageSize,jsonpCallback:'userCollects'},
	  success:function(data){
		 layer.close(loading);
		 if(data.code==200){
			 var listdata = '';
			 for(var i in data.data.list){
				  var res = data.data.list[i];
				  listdata += ' <div class="nes_list" id="myagemt_'+res.id+'"><div class="nes_list_l"><img src="http://www.usources.cn/'+res.imgUrl+'" /></div><div class="nes_list_r"><h6>'+res.title+'<a href="javascript:;" style="float:right" onclick=delCollect(\''+res.id+'\')>删除</a></h6><p>'+res.briefIntro+'</p></div><div class="clear"></div></div>';
				 //listdata += '<tr id="myagemt_'+res.id+'"><td width="50%"><font color="#000">'+res.title+'</font></td><td width="50%"><a href="javascropt:;"><font color="000">'+res.briefIntro+'</font></a></td><td width="15%" align="center"><a href="javascript:;" onclick=delCollect(\''+res.id+'\')>删除</a></td></tr>';
			 }
			 $("#agentBody").empty().append(listdata);
			 if(searchConfig.condition ==0){
			 	var rInfo = data.data.info;
			 	var totalSize =  rInfo.hasOwnProperty('totalSize')?rInfo.totalSize:-1;
				var totalPages = $("#pageNav").data('all');
				if(totalSize != -1){
					totalPages = Math.ceil(totalSize/searchConfig.pageSize);
				}
				$("#pageNav").Page({
					totalPages:totalPages,//分页总数
					liNums: 5,//分页的数字按钮数(建议取奇数)
					activeClass: 'activP', //active 类样式定义
					callBack : function(page){
						getAgent(page);
					}
				});
				searchConfig.condition = 1;
			}
		}else{
			layer.msg('请先登录！',{icon:2});
			setTimeout(function(){ location.href ='login.html';},2000)
		}
	},dataType:'json'}
	 
  );	
}

function delCollect(agentId){
	layer.confirm('确认从您的收藏中移除这条Agent吗?', {
	  btn: ['确定','取消'], //按钮
	  title:'温馨提示'
	}, function(){
	   var url = "http://www.usources.cn/api/agent/delUserCollect";
	   var loading = layer.msg('正在删除收藏，请等候...', {icon: 16,time: 999999, shade: [0.3, '#000']});
	   $.ajax({
		  url:url+'?'+Math.random(),
		  type:'GET',
		   xhrFields: {
		   withCredentials: true
		  },
		  crossDomain:true,
		  data:{agentId:agentId,jsonpCallback:'delUserCollect'},
		  success:function(data){
			   layer.close(loading);
			   if(data.code==200){
				   layer.msg('删除成功！',{icon:1});
				   $('#myagemt_'+agentId).remove();
				   getAgent(1);
			   }else{
				   layer.msg('未知code的错误！',{icon:2});
			   }
			  
		  },dataType:'json'});
	}, function(){
		
	
	});

}
</script>